/*
 * Created by Federico Pisarello - SisDev Software (c) 2014 - fpisarello@gmail.com
 */

var actionForm = 'usuariosAction.php';
var joDataConfig = undefined;

function $_initConfig()
{
	//Add Click for All Buttons in Pop Form
	$('#btnExit').click( function(e) {
		$('#configDialog').dialog('close');
	});
		
	$('#btnGrabarConfig').click( function(e) {
		$_saveConfig();
	});
	
	$(".numeric").numericInt();
	
	$('#anno').val(joDataConfig.anno);
	$('#canPalomares').val(joDataConfig.canPalomares);
	$('#canPalomaresFondo').val(joDataConfig.canPalomaresFondo);
	$('#porPuntos').val(joDataConfig.porPuntos);
}

function $_saveConfig()
{
	$('#btnGrabarConfig').attr('disabled','disabled');
	
	var paramData = 'actionOfForm=grabarConfig' + 
						'&anno=' + $('#anno').val() + 
						'&canPalomares=' + $('#canPalomares').val() + 
						'&canPalomaresFondo=' + $('#canPalomaresFondo').val() + 
						'&porPuntos=' + $('#porPuntos').val();
		
    $.ajax({
        type: 'POST',
        url: actionForm,
        data: paramData,
		dataType: 'json',
        success: function(jsonObj){
            if(jsonObj.status === 'OK'){
				$_showMessage('OK', jsonObj.status, jsonObj.msg);
				$('#configDialog').dialog('close');
			}
			else
				$_showMessage('ERR', jsonObj.status, jsonObj.msg);
            $('#btnGrabarConfig').removeAttr('disabled');
        }
    });

    return true;
}